home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Appearance SDK 1.0.4 / Appearance Sample Code / Source / BaseWindow.cp < prev    next >
Encoding:
Text File  |  1999-07-16  |  2.0 KB  |  136 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        BaseWindow.cp
  3.  
  4.     Contains:    Base class for a window.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (MAA)    Matt Ackeret
  21.         (edv)    Ed Voas
  22.  
  23.     Change History (most recent first):
  24.  
  25.          <4>    10/28/97    MAA        Change DrawMenuBar to InvalMenuBar
  26.          <3>    10/28/97    edv        Use RadioGroup control!
  27.          <2>     10/8/97    MAA        Add DrawMenuBar in destructor
  28.          <1>     9/11/97    edv        First checked in.
  29. */
  30.  
  31. #include <MacWindows.h>
  32. #include "BaseWindow.h"
  33.  
  34. BaseWindow::BaseWindow()
  35. {
  36.     fWindow = nil;
  37. }
  38.  
  39. BaseWindow::BaseWindow( SInt16 resID )
  40. {
  41.     fWindow = GetNewCWindow( resID, NULL, (WindowRef)-1L );
  42.     ((WindowPeek)fWindow)->windowKind = 2000;
  43.     SetWRefCon( fWindow, (long)this );
  44. }
  45.  
  46. BaseWindow::~BaseWindow()
  47. {
  48.     MenuHandle theMenu;
  49.     
  50.     if ( fWindow ) DisposeWindow( fWindow );
  51.  
  52.     theMenu = GetMyMenu();
  53.     
  54.     if (theMenu)
  55.     {
  56.          DeleteMenu( (**theMenu).menuID );
  57.          DrawMenuBar();
  58.     }
  59. }
  60.  
  61. void
  62. BaseWindow::Idle()
  63. {
  64. }
  65.  
  66. void
  67. BaseWindow::AdjustMenus()
  68. {
  69. }
  70.  
  71. void
  72. BaseWindow::HandleMenuSelection( SInt16 menuID, SInt16 itemNo )
  73. {
  74. #pragma unused( menuID, itemNo )
  75. }
  76.  
  77. void
  78. BaseWindow::Activate( EventRecord& )
  79. {
  80.     MenuHandle theMenu = GetMyMenu();
  81.     
  82.     if ( theMenu )
  83.     {
  84.         InsertMenu( theMenu, 0 );
  85.         DrawMenuBar();
  86.     }
  87. }
  88.  
  89. void
  90. BaseWindow::Deactivate( EventRecord& )
  91. {
  92.     MenuHandle theMenu = GetMyMenu();
  93.  
  94.     if ( theMenu )
  95.     {
  96.         DeleteMenu( (**theMenu).menuID );
  97.         InvalMenuBar();
  98.     }
  99. }
  100.  
  101. void
  102. BaseWindow::Update( EventRecord& )
  103. {
  104.     BeginUpdate( fWindow );
  105.     Draw();
  106.     EndUpdate( fWindow );
  107. }
  108.  
  109. void
  110. BaseWindow::Draw()
  111. {
  112. }
  113.  
  114. void
  115. BaseWindow::HandleKeyDown( EventRecord& )
  116. {
  117. }
  118.  
  119. void
  120. BaseWindow::Resize( SInt16 width, SInt16 height )
  121. {
  122.     SizeWindow( fWindow, width, height, true );
  123. }
  124.  
  125. void
  126. BaseWindow::HandleClick( EventRecord& event )
  127. {
  128. #pragma unused( event )
  129. }
  130.  
  131. MenuHandle BaseWindow::GetMyMenu(void)
  132. {
  133.     return(nil);  // if someone hasn't overridden this, they don't have a menu to get!
  134. }
  135.  
  136.